package com.fgw.controller.backend;

import com.fgw.common.Const;
import com.fgw.common.ResponseCode;
import com.fgw.common.ServerResponse;
import com.fgw.pojo.Teacher;
import com.fgw.service.ITeacherlibService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

/**
 * Created by lyj on 2017/9/25.
 */
@Controller
@RequestMapping("/admin/TeacherManager/")
public class TeacherManagerAdminController {

    @Autowired
    private ITeacherlibService iTeacherlibService;

    /**
     * 后台分页查询师资库正在报名状态下的列表
     * @param session
     * @param pageNum
     * @param pageSize
     * @return
     */
    @RequestMapping(value = "list.do")
    @ResponseBody
    public ServerResponse getTeacherList(HttpSession session, @RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum,@RequestParam(value = "pageSize",defaultValue = "5")Integer pageSize){
        Teacher teacher= (Teacher) session.getAttribute(Const.CURRENT_USER);
        if (teacher==null){
            return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(),"用户未登录请先登录");
        }else {
            return  iTeacherlibService.getTeacherManagerList(pageNum,pageSize,'1');
        }
    }

}
